<?php
	require('../qcubed.inc.php');

	class SampleListForm extends QForm {
		// Local instance of the Meta DataGrid to list Samples
		protected $dtgSamples;

		// Create QForm Event Handlers as Needed

//		protected function Form_Exit() {}
//		protected function Form_Load() {}
//		protected function Form_PreRender() {}
//		protected function Form_Validate() {}

		protected function Form_Run() {
			// Security check for ALLOW_REMOTE_ADMIN
			// To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
			//QApplication::CheckRemoteAdmin();
		}

		protected function Form_Create() {
			$this->dtgSamples = new SampleDataGrid($this);
			$this->dtgSamples->CssClass = 'datagrid';
			$this->dtgSamples->AlternateRowStyle->CssClass = 'alternate';

			$this->dtgSamples->Paginator = new QPaginator($this->dtgSamples);
			$this->dtgSamples->ItemsPerPage = 20;
                        

			// Create the Other Columns (note that you can use strings for sample's properties, or you
			// can traverse down QQN::sample() to display fields that are down the hierarchy)
                        $this->dtgSamples->MetaAddColumn('Date');
			$this->dtgSamples->MetaAddColumn(QQN::Sample()->Org);
                        $this->dtgSamples->MetaAddColumn(QQN::Sample()->EuserObject);
			$this->dtgSamples->MetaAddColumn('Returnable');

                        $this->dtgSamples->AddRowAction(new QMouseOverEvent(), new QCssClassAction('selectedStyle'));
                        $this->dtgSamples->AddRowAction(new QMouseOutEvent(), new QCssClassAction());

                        $this->dtgSamples->RowActionParameterHtml = '<?= $_ITEM->Id ?>';
                        $this->dtgSamples->AddRowAction(new QClickEvent(), new QAjaxAction('dtgRow_Click'));


                    }


            protected function dtgRow_Click($strFormId, $strControlId, $strParameter) {
                $intId = intval($strParameter);
                $strEditPageUrl = __SAMPLES__. '/sample_edit.php/'. $intId;
                QApplication::Redirect($strEditPageUrl);

            }

		
	}
        SampleListForm::Run('SampleListForm','tpl/sample_list.tpl.php');
?>
